var t = require("../../../../@babel/runtime/helpers/typeof"), a = getApp();

Page({
    data: {
        status: "",
        config_status: "",
        config2: {},
        config3: {},
        income_name_text: "",
        username: "",
        password: "",
        password_again: "",
        apply_background: "",
        upload_flag: !0,
        apply_switch: !1
    },
    onLoad: function(t) {
        this.setData({
            status: "",
            config_status: ""
        }), this.checkrouter(), this.getData(), this.customizeIncome();
    },
    checkrouter: function() {
        var a = this;
        try {
            var e = function() {
                for (var t, e, n = wx.getStorageSync("yz_basic_info"), o = n.popularize_page.mini.vue_route, i = 0; i < o.length; i++) if ("enterprise_apply" == o[i]) return console.log(n.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: n.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
                a.setData({
                    apply_switch: null !== (t = null === (e = n.plugin_setting.sub_platform) || void 0 === e ? void 0 : e.apply_switch) && void 0 !== t && t
                });
            }();
            if ("object" === t(e)) return e.v;
        } catch (t) {
            console.log(t);
        }
    },
    onChange: function(t) {
        var a = t.detail;
        this.setData({
            username: a
        });
    },
    onChange_p: function(t) {
        var a = t.detail;
        this.setData({
            password: a
        });
    },
    onChange_p2: function(t) {
        var a = t.detail;
        this.setData({
            password_again: a
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.merchant.frontend.get-info");
        a._getNetWork({
            url: e,
            data: {},
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    status: e.data.status,
                    config_status: e.data.config_status,
                    config2: e.data.config2,
                    config3: e.data.config3,
                    independent_backend: e.data.independent_backend
                }), "" == e.data.apply_background ? t.setData({
                    upload_flag: !1
                }) : t.setData({
                    apply_background: e.data.apply_background
                }), e.data.lang && (t.setData({
                    title: e.data.lang.title,
                    merchant_people: e.data.lang.merchant_people
                }), wx.setNavigationBarTitle({
                    title: "".concat(t.data.merchant_people, "申请")
                }))) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    customizeIncome: function() {
        try {
            var t = wx.getStorageSync("mailLanguage");
            if (t) {
                var a = JSON.parse(t);
                this.setData({
                    income_name_text: a.income.income_name
                });
            }
        } catch (t) {}
    },
    goEnterproseCentre: function() {
        wx.navigateTo({
            url: "/packageB/member/enterprise/enterprise_index/enterprise_index"
        });
    },
    submit: function() {
        var t = this, e = {
            config_status: this.data.config_status,
            user: {
                username: t.data.username,
                password: t.data.password,
                password_again: t.data.password_again
            }
        }, n = a.getNetAddresss("plugin.merchant.frontend.merchant-apply.staff");
        a._postNetWork({
            url: n,
            data: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    status: e.data.status
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    goToGoods: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + a
        });
    },
    goHome: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    }
});